﻿using System;
using System.Collections.Generic;
using System.Configuration;
using ZilLion.Core.Log;

namespace ZilLion.Core.Unities.Config
{
    public class DefaultAppConfigProvider : IAppConfigProvider
    {
        private static readonly IDictionary<string, string> _appSetting = new Dictionary<string, string>();

        public DefaultAppConfigProvider()
        {
            //获取APPCONFIG
            try
            {
                foreach (var appkey in ConfigurationManager.AppSettings.AllKeys)
                    _appSetting.Add(appkey.ToLower(), ConfigurationManager.AppSettings[appkey]);

            }
            catch (Exception ex)
            {
                
                ZilLionLogManager.GetLogger().Error(ex:ex,tags:"程序初始化config时发生严重错误");
            }
         
        }

        public string GetAppSetting(string key)
        {
            return _appSetting.ContainsKey(key.ToLower()) ? _appSetting[key.ToLower()] : string.Empty;
        }

        public void SaveAppSetting(string key, string value)
        {
        }
    }
}